package com.qhww.wechatmsg.config;

import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/***
 * 接口文档配置信息
 * @author wangsong
 * @mail 1720696548@qq.com
 * @date 2020/11/20 0020 9:06
 * @version 1.0.0
 */
@Configuration
@EnableSwagger2
@Slf4j
public class SwaggerConfig {


    /**
     * 创建swagger 目录
     * @return
     */
    @Bean
    public Docket createDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("微信公众号测试")
                // 全局参数 -> 默认token参数
                //.globalOperationParameters(getGlobalParameter())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.qhww.wechatmsg"))// 自行修改为自己的包路径
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build()
                .useDefaultResponseMessages(false)
                .apiInfo(new ApiInfoBuilder()
                        .title("微信公众号")
                        .description("restful Swagger API 文档")
                        .termsOfServiceUrl("127.0.0.1")
                        .version("1.0.0")
                        .contact(new Contact("郭树平", "127.0.0.1", "1163989452qq.com"))
                        .build());
    }

}
